# --静态属性@property 实例对象调用类方法不用传、
# 就像调用属性一样(类名+函数名  不用'()'也不用传参数)--
class Room:
    '''@property  # 静态属性装饰器、函数调用的时候不用加'()'和调用属性一样'''
    def __init__(self,name,ower,length,width,heigh):
        self.name = name
        self.ower = ower
        self.lenght = length
        self.width = width
        self.heigh = heigh
    @property
    def calArea(self):
        return self.lenght*self.width
    @property  # 静态属性装饰器、函数调用的时候不用加'()'和调用属性一样
    def calVolum(self):
        return self.width*self.lenght*self.heigh
room1=Room('洋房','Bob',100,123,78)

print(room1.calArea)
print(room1.calVolum)

# ----类方法@classmethod、类不通过实例对象获取类详细信息----
class Food:
    foods='anpple','banner','orange'
    def getFood(self):
        print('通过实例对象获取到的结果是',self.foods)
    @classmethod # 类方法
    def acquireFood(cls):
        print('类通过类方法输出的是结果',cls.foods)
    @classmethod
    def tailinfo(cls):
        print('输出的类是%s' % cls)
        print('类通过类方法输出-->',cls.foods)
getter =Food()
print(getter.getFood())
print(Food.foods) # 类获取类本身的数据属性
print(Food.acquireFood())  # 类获取类本身的函数属性
print(Food.tailinfo())

# ------------类的静态方法----------------------
class Books:
    def __init__(self,bookName):
        self.bookName=bookName
    def pythonBook(self,bookName):
        print('通过实例r输出的输出结果',self.bookName)
    '''静态方法、名义上归类管理、不能使用变量和实例变量、只是类的工具包'''
    @staticmethod
    def languagesBooks(a,b,c):
        # 'languagesBooks': < staticmethod object at 0x0000025092DE8AC8 >
        print("%s,%s,%s,都是编辑类的书籍" % (a,b,c))
    def test(x,y):
        # 普通函数 'test': < function Books.test at 0x0000025092DEC048 >
        return x+y
r=Books('python')
print("<<<<<<<<<<<<<<<<<")
# print(Books.pythonBook.__dict__)
print(r.__dict__)
print(Books.__dict__)
print('通过类自己调用自己的函数属性结果是：',Books.pythonBook)
print("通过实例对象调用类的函数属性（需要传参数）",r.pythonBook('python'))
print("-------------")
print("静态方法、类调用无参数的结果",Books.languagesBooks)
# >>>  <function Books.languagesBooks at 0x000001A650996F28>
# print("静态方法、类调用无参数的结果",Books.languagesBooks())
#  >>> # TypeError: languagesBooks() missing 3 required positional arguments: 'a', 'b', and 'c'
print("静态方法、类调用传参数的结果",Books.languagesBooks('C','java','C++'))
print('静态方法、实例调用类的函数属性传参数的结果',r.languagesBooks('C','java','C++'))



